ass Solution {
public:
    string convert(string s, int numRows) {
        if(s.size()<=numRows||numRows==1)
        return s;
        string res;
        int line=0;
        while(line<numRows)
        {
            if(line==0||line==numRows-1)
            {
                int add=numRows-1;
                int tmp=line;
                while(tmp<s.size())
                {
                    res.push_back(s[tmp]);
                    tmp+=2*add;
                }
                line++;
                continue;
            }
            else
            {
                int add1=numRows-1-line;
                int add2=line;
                int tmp=line;
                int time=1;
                while(tmp<s.size())
                {
                    res.push_back(s[tmp]);
                    if(time%2!=0)
                    tmp+=2*add1;
                    else
                    tmp+=2*add2;
                    time++;
                }
            }
            line++;
        }
        return res;
    }
};
